<template>
  <el-table-column v-bind="col">
    <template v-slot:default="scope">
      <template v-if="col.children">
        <RecursionTableColumn
          v-for="colItem in col.children"
          :key="colItem.label"
          :col="colItem"
          :params="params"
        ></RecursionTableColumn>
      </template>
      <template v-if="!col.children">
        <template v-if="col.slot"><slot :name="col.prop"></slot></template>
        <template v-else>
          <span v-if="col.type == 'select' && col.dict">
            {{ col.dict.find((it) => it.value == scope.row[col.prop])?.label }}
          </span>
          <!-- <span v-else-if="col.formater">{{
            scope.row[col.prop] | formateInfo(col)
          }}</span> -->
          <span v-else>
            {{
              scope.row[col.prop] === 0 || scope.row[col.prop] === false
                ? scope.row[col.prop]
                : scope.row[col.prop] || col.emptyText || params.cellEmptyText
            }}
          </span>
        </template>
      </template>
    </template>
  </el-table-column>
</template>

<script setup>
import RecursionTableColumn from "./RecursionTableColumn.vue";
//敏感过滤
const desensitization = (str, start, end) => {
  let len = str.length;
  var firstStr = str.substr(0, start);
  let lastStr = end ? str.substr(end) : "";
  let middleStr = str
    .subString(start, len - Math.abs(end))
    .replace(/[\s\S]/gi, "*");
  return firstStr + middleStr + lastStr;
};

const props = defineProps({
  col: { type: Object, default: () => ({}) },
  params: { type: Object }
});
</script>

<style></style>
